package com.zw.mes.module.tecdrawsign.controller;


import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zw.mes.base.BaseController;
import com.zw.mes.common.JsonResult;
import com.zw.mes.entity.technology.DrawSign;
import com.zw.mes.module.cost.model.DictCommon;
import com.zw.mes.module.cost.service.DictCommonService;
import com.zw.mes.module.tecdrawsign.model.DictEnum;
import com.zw.mes.module.tecdrawsign.model.DrawSignModel;
import com.zw.mes.module.tecdrawsign.service.DrawCJSignService;
import com.zw.mes.module.tecdrawsign.service.DrawSignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

import static com.zw.mes.constant.Constant.GROUP_SPECTYPE;
import static com.zw.mes.constant.Constant.GROUP_WORKSHOP;

/**
 * @author mayongfeng
 * @version 1.0.0
 * @ClassName PurchasedController.java
 * @Description TODO
 * @createTime 2021年01月29日 09:06:00
 */
@Controller
@RequestMapping("/tecdrawcjsign")
@SuppressWarnings("all")
public class DrawCJSignController extends BaseController {

    @Autowired
    private DictCommonService dictCommonService;
    @Autowired
    private DrawCJSignService drawCJSignService;


/****************************************************生产厂图纸签收***********************************************************/
    /**
     * @Author mayongfeng
     * @Date 14:15 2021/1/29
     * @Description 页面跳转到生产厂图纸签收记录
     *
     **/
    @GetMapping
    public String signList(Model model){
        model.addAttribute("special", dictCommonService.findDictByGroupName(GROUP_SPECTYPE));
        model.addAttribute("workshop", dictCommonService.findDictByGroupName(GROUP_WORKSHOP));
        return "technology/sign/drawCJLssue";
    }

    /**
     * @Author mayongfeng
     * @Date 10:52 2020/11/26
     * @Description 查询所有的图纸变更记录
     *
     **/
    @ResponseBody
    @PostMapping("/list")
    public JsonResult getAll(DrawSignModel drawSignModel){
        startPage();
        List<DrawSignModel> drawChaRecords = drawCJSignService.getCJAll(drawSignModel);
        return jsonResult(drawChaRecords);
    }




/**************************************************生产厂图纸变更签收*********************************************************/
    /**
     * @Author mayongfeng
     * @Date 14:15 2021/1/29
     * @Description 页面跳转到图纸变更签收记录
     *
     **/
    @GetMapping("changSign")
    public String changSign(Model model){
        model.addAttribute("special", dictCommonService.findDictByGroupName(GROUP_SPECTYPE));
        return "technology/sign/drawChaCJLssue";
    }

    /**
     * @Author mayongfeng
     * @Date 10:52 2020/11/26
     * @Description 查询所有的图纸变更记录
     *
     **/
    @ResponseBody
    @PostMapping("cha/list")
    public JsonResult getChaAll(DrawSignModel drawSignModel){
        startPage();
        List<DrawSignModel> drawDistrRecords = drawCJSignService.getChaCJAll(drawSignModel);
        return jsonResult(drawDistrRecords);
    }

 /**
     * @Author mayongfeng
     * @Date 10:52 2020/11/26
     * @Description 生产厂签收
     *
     **/
    @ResponseBody
    @PostMapping("cjSign")
    public JsonResult cjSign(Integer id,Integer changeType){
        startPage();
        int i = drawCJSignService.updateCjSign(id,changeType);
        return jsonResult(i);
    }





}
